import request from '../../utils/request';
import {sign} from '../api';
import {stringify} from 'qs';

export async function getChannelStatistics(params) {
  return request(`/api/user/statistics/getChannelStatistics?${stringify(params)}&sign=${sign(params)}`);
}

export async function deleteChannel(params) {//下线渠道
  return request(`/api/user/system/channel/deleteChannel?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

export async function getDayChannelStatisticsList(params) {
  return request(`/api/user/statistics/getDayChannelStatisticsList?${stringify(params)}&sign=${sign(params)}`);
}

export async function getSystemChannelList(params) {
  return request(`/api/user/statistics/getSystemChannelList?${stringify(params)}&sign=${sign(params)}`);
}

export async function onLineChannel(params) {//下线渠道
  return request(`/api/user/system/channel/onLineChannel?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

export async function insertChannel(params) {//新增渠道
  return request(`/api/user/system/channel/insertChannel?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//转化率
export async function getConversionList(params) {
  return request(`/api/user/statistics/getConversionList?${stringify(params)}&sign=${sign(params)}`);
}

export async function getChannelConversion(params) {
  return request(`/api/user/statistics/getChannelConversion?${stringify(params)}&sign=${sign(params)}`);
}

//今日统计
export async function todayStatCount(params) {
  return request(`/api/bill/stat/todayStatCount?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计-按期回款-今日已还
export async function loanEndRepayCount(params) {
  return request(`/api/bill/stat/loanEndRepayCount?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计-按期回款-折线图
export async function repayRateCount(params) {
  return request(`/api/bill/stat/repayRateCount?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计-按期回款-表格
export async function loanEndRepayTable(params) {
  return request(`/api/bill/stat/loanEndRepayTable?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计-逾期回款-今日逾期还款
export async function overdueRepayCount(params) {
  return request(`/api/bill/stat/overdueRepayCount?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计-逾期还款-折线图
export async function overdueRepayTrend(params) {
  return request(`/api/bill/stat/overdueRepayTrend?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计 -逾期回款-表格
export async function overdueRepayTable(params) {
  return request(`/api/bill/stat/overdueRepayTable?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计 -总回款
export async function totalRepayCount(params) {
  return request(`/api/bill/stat/totalRepayCount?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计 -总回款-表格
export async function totalRepayTable(params) {
  return request(`/api/bill/stat/totalRepayTable?${stringify(params)}&sign=${sign(params)}`);
}
//逾期统计-表格
export async function overdueCountTable(params) {
  return request(`/api/bill/stat/overdueCountTable?${stringify(params)}&sign=${sign(params)}`);
}
//逾期统计-折线图
export async function overdueCountTrend(params) {
  return request(`/api/bill/stat/overdueCountTrend?${stringify(params)}&sign=${sign(params)}`);
}
//逾期统计-饼状图
export async function overdueCountPie(params) {
  return request(`/api/bill/stat/overdueCountPie?${stringify(params)}&sign=${sign(params)}`);
}
//毛利润统计
export async function profitCountTable(params) {
  return request(`/api/bill/stat/profitCountTable?${stringify(params)}&sign=${sign(params)}`);
}
//风控统计
export async function riskCountTable(params) {
  return request(`/api/bill/stat/riskCountTable?${stringify(params)}&sign=${sign(params)}`);
}


//今日统计 想美
export async function todayStatCountForXBeauty(params) {
  return request(`/api/loan/stat/todayStatCount?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计-按期回款-今日已还 想美
export async function loanEndRepayCountForXBeauty(params) {
  return request(`/api/loan/stat/loanEndRepayCount?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计-按期回款-折线图 想美
export async function repayRateCountForXBeauty(params) {
  return request(`/api/loan/stat/repayRateCount?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计-按期回款-表格 想美
export async function loanEndRepayTableForXBeauty(params) {
  return request(`/api/loan/stat/loanEndRepayTable?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计-逾期回款-今日逾期还款 想美
export async function overdueRepayCountForXBeauty(params) {
  return request(`/api/loan/stat/overdueRepayCount?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计-逾期还款-折线图 想美
export async function overdueRepayTrendForXBeauty(params) {
  return request(`/api/loan/stat/overdueRepayTrend?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计 -逾期回款-表格 想美
export async function overdueRepayTableForXBeauty(params) {
  return request(`/api/loan/stat/overdueRepayTable?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计 -总回款 想美
export async function totalRepayCountForXBeauty(params) {
  return request(`/api/loan/stat/totalRepayCount?${stringify(params)}&sign=${sign(params)}`);
}
//回款统计 -总回款-表格 想美
export async function totalRepayTableForXBeauty(params) {
  return request(`/api/loan/stat/totalRepayTable?${stringify(params)}&sign=${sign(params)}`);
}
//逾期统计-表格 想美
export async function overdueCountTableForXBeauty(params) {
  return request(`/api/loan/stat/overdueCountTable?${stringify(params)}&sign=${sign(params)}`);
}
//逾期统计-折线图 想美
export async function overdueCountTrendForXBeauty(params) {
  return request(`/api/loan/stat/overdueCountTrend?${stringify(params)}&sign=${sign(params)}`);
}
//逾期统计-饼状图 想美
export async function overdueCountPieForXBeauty(params) {
  return request(`/api/loan/stat/overdueCountPie?${stringify(params)}&sign=${sign(params)}`);
}
//毛利润统计 想美
export async function profitCountTableForXBeauty(params) {
  return request(`/api/loan/stat/profitCountTable?${stringify(params)}&sign=${sign(params)}`);
}
//风控统计 想美
export async function riskCountTableForXBeauty(params) {
  return request(`/api/loan/stat/riskCountTable?${stringify(params)}&sign=${sign(params)}`);
}

//获取第三方所有渠道转化
export async function getTotalChannelConversion(params) {
  return request(`/api/user/statistics/getTotalChannelConversion?${stringify(params)}&sign=${sign(params)}`);
}

//获取第三方所有渠道统计
export async function getTotalChannelStatistics(params) {
  return request(`/api/user/statistics/getTotalChannelStatistics?${stringify(params)}&sign=${sign(params)}`);
}

//获取时间段内的新用户转化率
export async function getTotalConversionList(params) {
  return request(`/api/user/statistics/getTotalConversionList?${stringify(params)}&sign=${sign(params)}`);
}

//用户转化详情列表
export async function getConversionListForExternal(params) {
  return request(`/api/user/statistics/getConversionListForExternal?${stringify(params)}&sign=${sign(params)}`);
}

//昨日,今日转化详情
export async function getConversionForExternal(params) {
  return request(`/api/user/statistics/getConversionForExternal?${stringify(params)}&sign=${sign(params)}`);
}

//获取标签列表
export async function getUserLabels(params) {
  return request(`/api/user/userLabel/getLabels?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//给用户添加标签
export async function postAddLabel(params) {
  return request(`/api/user/userLabel/addLabel?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//取消对用户的重点关注
export async function postCancelFocus(params) {
  return request(`/api/user/userLabel/cancleFoucus?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}


//设置对用户的重点关注
export async function postSetFocus(params) {
  return request(`/api/user/userLabel/focus?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//昨日,今日转化详情
export async function getConversionGeneralListForExternal(params) {
  return request(`/api/user/statistics/getConversionGeneralListForExternal?${stringify(params)}&sign=${sign(params)}`);
}

//取得风控列表
export async function getUserCenterRiskList(params) {
  return request(`/api/user/statistics/getUserCenterRiskList?${stringify(params)}&sign=${sign(params)}`);
}

//取得用户列表
export async function getUserCenterUserList(params) {
  return request(`/api/user/statistics/getUserCenterUserList?${stringify(params)}&sign=${sign(params)}`);
}

//--红包模块
//获得红包的操作记录
export async function getRedPacketOperate(params) {
  return request(`/api/user/redPacket/getRedPacketOperate?${stringify(params)}&sign=${sign(params)}`);
}

//红包上下线
export async function postDeleteRedPacketType(params) {
  return request(`/api/user/redPacket/deleteRedPacketType?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//发放红包
export async function postGiveRedPacket(params) {
  return request(`/api/user/redPacket/giveReadPacket?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//新增红包
export async function postAddRedPacket(params) {
  return request(`/api/user/redPacket/add?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//修改红包金额
export async function postUpdateRedPacketTypeAmount(params) {
  return request(`/api/user/redPacket/updateRedPacketTypeAmount?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//发放红包时获取可用红包
export async function getRedPacketTypeListBySource(params) {
  return request(`/api/user/redPacket/getRedPacketTypeListBySource?${stringify(params)}&sign=${sign(params)}`);
}

//按照条件查询红包
export async function getRedPacketTypeList(params) {
  // return request(`/api/user/redPacket/getRedPacketTypeList?${stringify(params)}&sign=${sign(params)}`);
  return request(`/api/user/redPacket/getRedPacketTypeList?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: params,
  });
}

//获得每个产品红包的统计
export async function getRedPacket(params) {
  return request(`/api/user/redPacketStatistics/getRedPacket?${stringify(params)}&sign=${sign(params)}`);
}

//获得所有红包统计
export async function getTotalRedPacket(params) {
  return request(`/api/user/redPacketStatistics/getTotalRedPacket?${stringify(params)}&sign=${sign(params)}`);
}

//获得每天红包的统计
export async function getDayRedPacket(params) {
  // return request(`/api/user/redPacketStatistics/getDayRedPacket?${stringify(params)}&sign=${sign(params)}`);
  return request(`/api/user/redPacketStatistics/getDayRedPacket?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: params,
  });
}

//红包发放记录
export async function getReadPacketGiveList(params) {
  // return request(`/api/user/redPacket/getReadPacketGiveList?${stringify(params)}&sign=${sign(params)}`);
  return request(`/api/user/redPacket/getReadPacketGiveList?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: params,
  });
}

//查询所有贷超列表
export async function getAllCreditMarket(params) {
  return request(`/api/user/creditMarket/all?${stringify(params)}&sign=${sign(params)}`);
}

//新增贷超
export async function postAddCreditMarket(params) {
  // return request(`/api/user/redPacket/getReadPacketGiveList?${stringify(params)}&sign=${sign(params)}`);
  return request(`/api/user/creditMarket/add?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//贷超修改
export async function postUpdateCreditMarket(params) {
  // return request(`/api/user/redPacket/getReadPacketGiveList?${stringify(params)}&sign=${sign(params)}`);
  return request(`/api/user/creditMarket/update?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//贷超删除
export async function postDelCreditMarket(params) {
  // return request(`/api/user/redPacket/getReadPacketGiveList?${stringify(params)}&sign=${sign(params)}`);
  return request(`/api/user/creditMarket/del?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}


//===========分期展示模块=========================

export async function versionList(params) {//版本列表
  return request(`/api/user/version/list?${stringify(params)}&sign=${sign(params)}`);
}
export async function addVersion(params) {//添加版本列表
  return request(`/api/user/version/addVersion?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

export async function updateInstallmentStatus(params) {//修改分期状态
  return request(`/api/user/version/updateInstallmentStatus?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

export async function updateVersion(params) {//修改版本
  return request(`/api/user/version/updateVersion?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

export async function getChannelAndVersionQuery(params) {//渠道版本列表
  return request(`/api/user/version/getChannelAndVersionQuery?${stringify(params)}&sign=${sign(params)}`);
}
/*============功能槽设置 =================*/

export async function addFunction(params) {//新增功能槽配置
  return request(`/api/user/functionConfig/addFunction?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}
export async function getFunctionList(params) {//根据条件获得功能槽
  return request(`/api/user/functionConfig/getFunctionList?sign=${sign(params)}`, {
    method: 'POST',
    body: params,
  });
}
export async function onoffFunction(params) {//功能槽上下线
  return request(`/api/user/functionConfig/onoffFunction?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}
export async function updateFunction(params) {//编辑功能槽配置
  return request(`/api/user/functionConfig/updateFunction?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}
//-----------banner----------//

//新增banner
export async function postAddBanner(params) {
  return request(`/api/user/banner/addBanner?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//获取banner列表
export async function getBannerList(params) {
  return request(`/api/user/banner/getBannerList?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: params,
  });
}

//编辑banner
export async function postUpdateBanner(params) {
  return request(`/api/user/banner/updateBanner?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//banner下线
export async function postOffBanner(params) {
  return request(`/api/user/banner/onoffBanner?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//banner批量上线
export async function postOnBanner(params) {
  return request(`/api/user/banner/offBathBanner?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//获取所有的版本号
export async function getVersionBySource(params) {
  return request(`/api/user/version/getVersionBySource?${stringify(params)}&sign=${sign(params)}`);
}


//-----------闪屏----------//

//新增闪屏
export async function postAddScreen(params) {
  return request(`/api/user/screen/addScreen?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//获取闪屏列表
export async function getScreenList(params) {
  return request(`/api/user/screen/getScreenList?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: params,
  });
}

//编辑闪屏
export async function postUpdateScreen(params) {
  return request(`/api/user/screen/updateScreen?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//闪屏下线
export async function postOnoffScreen(params) {
  return request(`/api/user/screen/onoffScreen?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}


//-----------首页图标----------//

//新增首页图标
export async function postAddIcon(params) {
  return request(`/api/user/icon/addIcon?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//获取首页图标列表
export async function getIconList(params) {
  return request(`/api/user/icon/getIconList?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: params,
  });
}

//编辑首页图标
export async function postUpdateIcon(params) {
  return request(`/api/user/icon/updateIcon?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//首页图标下线
export async function postOffIcon(params) {
  return request(`/api/user/icon/onoffIcon?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//首页图标批量上线
export async function postOnIcon(params) {
  return request(`/api/user/icon/offBathIcon?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//--风控中心

//获取通过率
export async function getUserPassRate(params) {
  return request(`/api/user/getUserPassRate?${stringify(params)}&sign=${sign(params)}`);
}

//编辑通过率阈值
export async function updatePassRateConf(params) {
  return request(`/api/user/systemConfig/updatePassRateConf?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//获取当前通过率阈值
export async function getPassRateConf(params) {
  return request(`/api/user/systemConfig/getPassRateConf?${stringify(params)}&sign=${sign(params)}`);
}

